import { CHANGE_INPUT_VALUE, ADD_ITEM, DEL_ITEM, GET_LIST } from './constants'
import axios from 'axios'

export const changeInputValueAction = (value) => ({
  type: CHANGE_INPUT_VALUE,
  value
})

export const addItemAction = () => ({
  type: ADD_ITEM
})

export const delItemAction = (index) => ({
  type: DEL_ITEM,
  value: index
})

export const getListAction = value => ({
  type: GET_LIST,
  value
})

export const getSystemList = () => {
  return dispatch => {
    axios.get('https://mstest.viomi.com.cn/auth-web/services/systems/userSystem?token=9P7qKKGS3xzbP6G7&typeStr=1,3').then((res) => {
      const data = res.data.mobBaseRes.datas
      const action = getListAction(data)
      dispatch(action)
    })
  }
}